package com.qfedu.service;

import com.alibaba.fastjson.JSONObject;
import com.qfedu.dao.UserDao;
import com.qfedu.entity.Consumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhang
 * @Title: commonValidateAdd
 * @date : 2022/2/25 8:15
 */
@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserDao userDao;

    @Override
    public List<Consumer> findAllConsumer() {
        return userDao.findAllConsumer();
    }

    @Override
    public List<Consumer> findAllConsumerById(int id) {
        return userDao.findAllConsumerById(id);
    }

    @Override
    public int deleteConsumerById(Consumer consumer) {
        return userDao.deleteConsumerById(consumer);
    }

    @Override
    public int addConsumer(Consumer consumer) {
        return userDao.addConsumer(consumer);
    }

    @Override
    public int updateConsumer(Consumer consumer) {
        return userDao.updateConsumer(consumer);
    }

    @Override
    public JSONObject updateConsumerById(Consumer consumer) {
        int i = userDao.updateConsumerById(consumer);
        JSONObject jsonObject = new JSONObject();

        if (1 != 0){
            jsonObject.put("code",1);
            jsonObject.put("msg","修改成功");
        }else {
            jsonObject.put("code",0);
            jsonObject.put("msg","修改成功");
        }
        return jsonObject;
    }


}
